<?php /* Template Name: Projekty VTP */ ?>
<?php
get_header();
?>

<?php
if (!isset($_GET['category1'])) {
    $_GET['category1'] = 5;
}
if (!isset($_GET['category2'])) {
    $_GET['category2'] = 8;
}

// prida odkazu class="current"
function isCurrent($number, $cat) {
    if ($cat == 1) 
        if ($_GET['category1'] == $number) return 'class="current"';
    if ($cat == 2) 
        if ($_GET['category2'] == $number) return 'class="current"';
    return '';
}
?>

<div id="categoryMenu">
    <ul class="categoryMenu-1">
    <?php
        $page = '?page_id='.$_GET['page_id'];
        $cat2 .= '&category2='.$_GET['category2'];
        echo '<li><a href="'.$page.'&category1=5'.$cat2.'" '.isCurrent(5, 1).'>Študent</a></li>';
        echo '<li><a href="'.$page.'&category1=6'.$cat2.'" '.isCurrent(6, 1).'>Firma</a></li>';
        echo '<li><a href="'.$page.'&category1=7'.$cat2.'" '.isCurrent(7, 1).'>Vedec</a></li>';
    ?>
    </ul>
    <ul class="categoryMenu-2">
    <?php
        $cat1 .= '&category1='.$_GET['category1'];    
        echo '<li><a href="'.$page.$cat1.'&category2=8" '.isCurrent(8, 2).'>Lokálne</a></li>';
        echo '<li><a href="'.$page.$cat1.'&category2=11" '.isCurrent(11, 2).'>Národné</a></li>';
        echo '<li><a href="'.$page.$cat1.'&category2=12" '.isCurrent(12, 2).'>Medzinárodné</a></li>';
    ?>
    </ul>    
    
</div>
<div class="clearer"></div>
<h2>Projekty</h2>
<hr class="h2hr" /><div class="clearer"></div>'
<?php
$projects = $vtpProjects->getProjects($_GET['category1'], $_GET['category2']);          

foreach ($projects as $project) {
    echo '<div class="project-item">';
    echo '<div class="project-item-logo">';
    jr_post_image($project->post_id);
    echo '</div>';
    echo '<span class="project-item-name"><a href="'.get_permalink($project->post_id).'">'.$project->name;
    if ($project->abbrevation != '') {
        echo ' ('.$project->abbrevation.')';
    }
    echo '</a></span>';

    echo '<span class="project-item-perex">'.substr($project->perex, 0, 100).' ...</span>';
    echo '</div>';
}
?>

<?php
get_footer();
?>